package ed.hbut.supermarket1.mapper;

import ed.hbut.supermarket1.entity.Supplier;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SupplierMapper {

    @Select("select * from supplier ")
    List<Supplier> getAllSupplier();

    @Insert("insert into supplier(SupplierName, SupplierPhone, SupplierAddress, SupplierState) VALUE (#{supplierName},#{supplierPhone},#{supplierAddress},#{supplierState})")
    void addSupplier(Supplier supplier);

    @Select("select * from supplier where SupplierID=#{id}")
    Supplier getSupplierById(int id);

    @Update("update supplier set SupplierName=#{supplierName},SupplierAddress=#{supplierAddress},SupplierPhone=#{supplierPhone},SupplierState=#{supplierState} where SupplierID=#{supplierId}")
    void updataSupplier(Supplier supplier);

    @Delete("delete from supplier where SupplierID=#{id}")
    void deleteSupplier(int id);

    @Select("select supplier.SupplierName from supplier where SupplierID=#{id}")
    String getNameById(int id);
}
